package com.pcbly.web.bean.chart;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.pcbly.web.bean.AbstractBaseBean;

public class ChartPropertyBean extends AbstractBaseBean {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3465944027413276939L;

	public enum ValueTypeEnum {
		String, Integer, Float, Boolean, DateTime
	}

	private ChartBean chartBean;
	private String schema;
	private String value;
	private String desc;
	private ValueTypeEnum type;

	public ChartPropertyBean() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		return EqualsBuilder.reflectionEquals(this, object);
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.MULTI_LINE_STYLE);
	}

	public ChartBean getChartBean() {
		return chartBean;
	}

	public void setChartBean(ChartBean chartBean) {
		this.chartBean = chartBean;
	}

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public ValueTypeEnum getType() {
		return type;
	}

	public String getStringType() {
		// String,Integer,Float,Boolean,DateTime
		switch (type) {
		case String:
			return "String";
		case Integer:
			return "Integer";
		case Float:
			return "Float";
		case Boolean:
			return "Boolean";
		case DateTime:
			return "DateTime";
		default:
			return "String";
		}
	}

	public ValueTypeEnum ConvertValueTypeToEnum(String strValueType) {
		ValueTypeEnum m_ValueType = ValueTypeEnum.String;
		String str = strValueType.toLowerCase();
		if ("string".equals(str)) {
			m_ValueType = ValueTypeEnum.String;
		} else if ("integer".equals(str)) {
			m_ValueType = ValueTypeEnum.Integer;
		} else if ("float".equals(str)) {
			m_ValueType = ValueTypeEnum.Float;
		} else if ("boolean".equals(str)) {
			m_ValueType = ValueTypeEnum.Boolean;
		} else if ("datetime".equals(str)) {
			m_ValueType = ValueTypeEnum.DateTime;
		} else {
			m_ValueType = ValueTypeEnum.String;
		}
		return m_ValueType;
	}

	public void setType(ValueTypeEnum type) {
		this.type = type;
	}

}
